#
# Makefile for 'test'.
#
# Type 'make' or 'make test' to create the binary.
# Type 'make clean' or 'make clear' to delete all temporaries.
# Type 'make run' to execute the binary.
# Type 'make debug' to debug the binary using gdb(1).
#

# build target specs
CC = g++
CFLAGS = -O3 
OUT_DIR = release
LIBS =

# first target entry is the target invoked when typing 'make'
default: test

test: $(OUT_DIR)/BasePlusCommissionEmployee.cpp.o $(OUT_DIR)/CommissionEmployee.cpp.o $(OUT_DIR)/Date.cpp.o $(OUT_DIR)/Employee.cpp.o $(OUT_DIR)/HourlyEmployee.cpp.o $(OUT_DIR)/SalariedEmployee.cpp.o $(OUT_DIR)/test.cpp.o
	$(CC) $(CFLAGS) -o test $(OUT_DIR)/BasePlusCommissionEmployee.cpp.o $(OUT_DIR)/CommissionEmployee.cpp.o $(OUT_DIR)/Date.cpp.o $(OUT_DIR)/Employee.cpp.o $(OUT_DIR)/HourlyEmployee.cpp.o $(OUT_DIR)/SalariedEmployee.cpp.o $(OUT_DIR)/test.cpp.o $(LIBS)

$(OUT_DIR)/BasePlusCommissionEmployee.cpp.o: \
 BasePlusCommissionEmployee.cpp BasePlusCommissionEmployee.h \
 CommissionEmployee.h Employee.h Date.h
	$(CC) $(CFLAGS) -o $(OUT_DIR)/BasePlusCommissionEmployee.cpp.o -c BasePlusCommissionEmployee.cpp

$(OUT_DIR)/CommissionEmployee.cpp.o: CommissionEmployee.cpp \
 CommissionEmployee.h Employee.h Date.h
	$(CC) $(CFLAGS) -o $(OUT_DIR)/CommissionEmployee.cpp.o -c CommissionEmployee.cpp

$(OUT_DIR)/Date.cpp.o: Date.cpp Date.h
	$(CC) $(CFLAGS) -o $(OUT_DIR)/Date.cpp.o -c Date.cpp

$(OUT_DIR)/Employee.cpp.o: Employee.cpp Employee.h Date.h
	$(CC) $(CFLAGS) -o $(OUT_DIR)/Employee.cpp.o -c Employee.cpp

$(OUT_DIR)/HourlyEmployee.cpp.o: HourlyEmployee.cpp HourlyEmployee.h \
 Employee.h Date.h
	$(CC) $(CFLAGS) -o $(OUT_DIR)/HourlyEmployee.cpp.o -c HourlyEmployee.cpp

$(OUT_DIR)/SalariedEmployee.cpp.o: SalariedEmployee.cpp \
 SalariedEmployee.h Employee.h Date.h
	$(CC) $(CFLAGS) -o $(OUT_DIR)/SalariedEmployee.cpp.o -c SalariedEmployee.cpp

$(OUT_DIR)/test.cpp.o: test.cpp Employee.h Date.h SalariedEmployee.h \
 HourlyEmployee.h CommissionEmployee.h BasePlusCommissionEmployee.h
	$(CC) $(CFLAGS) -o $(OUT_DIR)/test.cpp.o -c test.cpp

run:
	./test 

debug:
	gdb ./test

clean:
	@echo -n 'Removing all temporary binaries... '
	@rm -f test $(OUT_DIR)/*.o
	@echo Done.

clear:
	@echo -n 'Removing all temporary binaries... '
	@rm -f test $(OUT_DIR)/*.o
	@echo Done.

